// 项目审批列表：用approveResult    type=1
// 项目库列表：用project.approveStatus   type=2
// 项目申报列表：用project.approveStatus   type=2
// 详情页：用list接口里的result             type=3
// 项目填报：用approveStatus             type=4

export const getStatus = (data, type) => {
  let { approveStatus, approveResult, project = {}, result } = data;
  let approveData; // 0 待审批 , 1 已通过, 2 未通过
  // 通过状态判断
  const fromResult = value => {
    return (approveData = value === true ? 1 : value === false ? 2 : 0);
  };

  const fromStatus = status => {
    return (approveData =
      status === 'PASS'
        ? 1
        : status === 'REFUSE'
        ? 2
        : status == 'GOING'
        ? 3
        : 0);
  };
  if (type == 1) {
    return fromResult(approveResult && approveResult.result);
  } else if (type == 3) {
    return fromResult(result);
  } else if (type == 4) {
    return fromStatus(approveStatus);
  } else {
    return fromStatus(project.approveStatus);
  }
};
